package cn.Quartz.Job;

import cn.CommonUtils.ApplicationConfigurationSingletonFactory;
import lombok.extern.slf4j.Slf4j;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.context.ContextLoader;
import org.springframework.web.context.WebApplicationContext;

import java.time.LocalDateTime;

@Slf4j
public class GenerateReport2Job implements Job {
    public GenerateReport2Job() {
    }
    public void execute(JobExecutionContext context)
            throws JobExecutionException {
        log.info("Hello Job Message start in : "+ LocalDateTime.now().toString());
        WebApplicationContext wac = ContextLoader.getCurrentWebApplicationContext();
//        Object obj = wac.getBean(GenerateReportToExcel.class);
//        GenerateReportToExcel generateReportToExcel = (GenerateReportToExcel) obj;

        String generateReportUrl = ApplicationConfigurationSingletonFactory.getValueOfConfiguration("GenerateReportUrl2");
        log.info("gnerateReportUrl2："+generateReportUrl);

        String result = new String();

        try {
            RestTemplate restTemplate = new RestTemplate();
            result = restTemplate.getForObject(generateReportUrl, String.class);
            log.info(result);
        } catch (Exception e) {
            log.error(e.getMessage());
        }

//        generateReportToExcel.generatePlatinumBagRedEnvelopeRecord();



        log.info(result);

/*
        if (generateReportToExcel == null) {
            log.error("generateReportToExcel object is null");
            return;
        }

        generateReportToExcel.generatePlatinumBagConsumeScanCodeRecord();*/

        log.info("Hello Job Message end in : "+ LocalDateTime.now().toString());
    }
}
